package com.hongshan.wallet.core.wallet

import com.hongshan.wallet.BR
import com.hongshan.wallet.MyApplication
import com.hongshan.wallet.R
import com.hongshan.wallet.base.BaseRecyclerAdapter
import com.hongshan.wallet.base.BaseViewHolder
import com.hongshan.wallet.base.MyViewModel
import com.hongshan.wallet.bean.MoneyRecordBean

/**
 * Copyright Zhangxx.
 * Copyright (c) 2019
 * All rights reserved
 *
 * @project  : Wallet
 * @package  : com.example.wallet.core.home
 * @author   : zhangxx
 * @date     : 2019/3/28
 * @email    : qq957413212@hotmail.com
 * @desc     : //TODO
 */
class CommissionRecycleAdapter(val list: ArrayList<MoneyRecordBean>): BaseRecyclerAdapter() {

    override fun getViewModel(holder: BaseViewHolder<MyViewModel>, position: Int): CommissionRecycleViewModel {
        val viewModel = CommissionRecycleViewModel(MyApplication.applicationContext)
        viewModel.setMoneyRecord(list[position])
        return viewModel
    }

    override fun getLayoutIdForPosition(position: Int) = R.layout.list_item_commission

    override fun initVariableId(position: Int) = BR.vm

    override fun getItemCount(): Int {
        val size = super.getItemCount()
        return if (size == 0) list.size else size
    }

    override fun isEmpty() = list.size == 0
}